package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Focus;
import com.sk.bilibili.bean.Member;
import com.sk.bilibili.dto.FocusInfo;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.FocusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 邵康
 * @date 2021/11/24 09:26
 */
@CrossOrigin
@RestController
@RequestMapping("/focus")
@Api(tags = "关注")
public class FocusController {

    @Autowired
    private FocusService focusService;

    @ApiOperation("add")
    @PostMapping("/add")
    public R<Void> add(@RequestBody Focus focus) {
        return focusService.add(focus);
    }

    @ApiOperation("判断是否对象以及关注")
    @GetMapping("/isFocus")
    public R<Boolean> isFocus(Integer focusId) {
        return focusService.isFocus(focusId);
    }

    @ApiOperation("切换关注状态，返回关注信息  为null 就是取消关注    默认会添加到默认分组")
    @GetMapping("/switchFocus")
    public R<Focus> switchFocus(Integer focusId) {
        return focusService.switchFocus(focusId);
    }

    @ApiOperation("deleteRes")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return focusService.delete(id);
    }

    @ApiOperation("更新 只能更新用户分组")
    @PostMapping("/update")
    public R<Void> update(@RequestBody Focus focus) {
        return focusService.update(focus);
    }

    @ApiOperation("pageSearch")
    @GetMapping("/page")
    public R<IPage<Focus>> page(@RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "20") Integer size) {
        return focusService.page(page, size);
    }

    @ApiOperation("分页获取关注的用户信息")
    @PostMapping("/focusMember")
    public R<IPage<Member>> focusMember(@RequestBody FocusInfo focusInfo) {
        return focusService.focusMember(focusInfo);
    }

    @ApiOperation("获取所有粉丝信息")
    @GetMapping("/followMember")
    public R<List<Member>> followMember(@RequestParam(required = false) Integer memberId) {
        return focusService.followMember( memberId);
    }

    @ApiOperation("移动关注对象到指定分组")
    @GetMapping("/move")
    public R<Void> move(Integer[] ids,Integer focusGroupId) {
        return focusService.move(ids,focusGroupId);
    }

}
